package com.happyclub.paul.service.impl;

import com.happyclub.paul.dao.PersonalPhotoAlbumRepostitory;
import com.happyclub.paul.service.PersonalPhotoAlbumService;
import com.happyclub.pojo.TbPersonalPhotoAlbum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @Auther: 魏泉琦
 * @Date: 2019/4/3 16:10
 * @Description: 用户相册中间表
 */
@Service
public class PersonalPhotoAlbumServiceImpl implements PersonalPhotoAlbumService {

    @Autowired
    private PersonalPhotoAlbumRepostitory personalPhotoAlbumRepostitory;



    /**
     *@Description: 保存用户和相册信息
     *@Author: 魏泉琦
     *@date: 2019/4/3
     */
    @Transactional
    @Override
    public Integer savePersonalPhotoAlbumMsg(String uid, String photoAlbumId) {
        return  personalPhotoAlbumRepostitory.savePersonalPhotoAlbumMsg(uid,photoAlbumId);
    }

    /**
     *@Description: 查询指定用户拥有的所有相册
     *@Author: 魏泉琦
     *@date: 2019/4/6
     */
    @Override
    public List<TbPersonalPhotoAlbum> showUserPhotoAlbum(String userId) {
        return personalPhotoAlbumRepostitory.showUserPhotoAlbum(userId);
    }


    /**
     *@Description: 根据相册编号删除该用户相册中数据
     *@Author: 魏泉琦
     *@date: 2019/4/6
     */
    @Transactional
    @Override
    public Integer deletePersonalPhotoAlbumByPhotoAlbumId(String photoAlbumId) {
        Integer cnt = 0;
        try{
            cnt = personalPhotoAlbumRepostitory.deletePersonalPhotoAlbumByPhotoAlbumId(photoAlbumId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return cnt;
    }
}
